#!/bin/sh
# prepro.sh - Preparing for all projects.

#修改源配置文件并更新软件
echo -n "Is the sources.list ready?[yes/no]: "
read list_ready
if [ "${list_ready}" != "yes" ]
then
    echo "Make sources.list be ready first!!"
    exit 1
fi
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cp -fv ./sources.list /etc/apt/sources.list
sudo cp -fv ./mkpro.sh /usr/bin/mkpro
sudo apt-get update
sudo apt-get upgrade

# 安装普通工具
echo "To install tools..."
sudo apt-get install unrar krusader xpdf gftp rapidsvn

# 安装编译工具
echo "To install build-essential vim-gtk cscope subversion subversion-tools"
sudo apt-get install build-essential vim-gtk cscope subversion subversion-tools
echo "To install meld and get_svn_log"
cd ./others
sudo cp get_svn_log /usr/bin/
sudo chmod +x /usr/bin/get_svn_log
tar jxvf meld*
cd meld
. install.sh
cd ..
rm -frv meld
# 进到tools/vim路径
cd ../vim
# 安装vim插件
echo "To install vimcdoc..."
tar zxvf 01vimcdoc-1.7.0.tar.gz
cd vimcdoc-1.7.0
sudo ./vimcdoc.sh -i
cd ..
rm -frv vimcdoc-1.7.0

echo "To install ctags..."
tar zxvf 02ctags-5.8.tar.gz
cd ctags-5.8
./configure --prefix=/usr && sudo make && sudo make install
cd ..
rm -frv ctags-5.8

echo "To install autoload plugin syntax vimrc..."
sudo cp -frv ./autoload/* /usr/share/vim/vim72/autoload/
sudo cp -frv ./plugin/* /usr/share/vim/vim72/plugin/
sudo cp -frv ./syntax/* /usr/share/vim/vim72/syntax/
sudo meld vimrc /etc/vim/vimrc &
# 回到tools下
cd ..

echo "To make tags: usr_include_tags for app;"
# 存放所有项目配置文件的总目录在~/jacob.pro下
pro_all=~/.jacob.pro
if [ ! -d ${pro_all} ]
then
    echo "Make a pro setting path for all at ~/.jacob.pro"
    mkdir ${pro_all}
else
    echo "Project setting path for all at ~/.jacob.pro"
fi
cd /usr/include
ctags -R --c-kinds=+p --fields=+S -f ${pro_all}/usr_include_tags

echo "Done"
